package sparkCode



case class pro(name:String,age:Int)


object HelloScala {

  def main(args: Array[String]): Unit = {

    val pro1=new pro("zhangyuhan",20)
    val pro2=new pro("xz",32)

    val proList=List(pro1,pro2)

    proList.foreach(x=>{
      x match{
        case pro("zhangyuhan",20)=>println("I am zhangyuhan ")
        case _=>println(" no match")
      }
    })



    //模式匹配   类似java中
    def matchTest( x: Any)={
          x match {
            case 1 => println("number is 1")
            case 2 => println("number is 2")
            case x: String => println("type is string")
            case _ => println("no match ")
          }

    }

    matchTest()
  }

}
